package cn.t.enums.user;

import cn.t.core.enums.base.CommonEnum;
import cn.t.core.exception.BizException;
import cn.t.core.enums.base.CommonError;
import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author l
 */

@Getter
@AllArgsConstructor
public enum PassportTypeEnum implements CommonEnum<Integer, String> {

    USER_NAME(1, "用户名"), PHONE_NUMBER(2, "手机号"), ENT_USER(3, "企业站用户ID"), EMP_CODE(4, "员工工号"), CARD_CODE(5, "员工卡号"), FACE(6, "人员识别");

    @JsonValue
    @EnumValue
    private final Integer code;
    private final String name;

    public static PassportTypeEnum getByCode(Integer source) {
        for (PassportTypeEnum value : PassportTypeEnum.values()) {
            if (value.code.equals(source)) {
                return value;
            }
        }

        throw new BizException(CommonError.ILLEGAL_PARAMETER);
    }

}
